

		* APPENDIX 9: Over-time Analyses with all Survey-Takers 
		
		* PART 2: survey takers from wave 1 to wavee 20
		
		
cd "$data"
use "panel.dta", clear 

* waves_taken112 // all waves takers from 1 to 12.
* waves_taken120 // all wave takers from 1 to 20


xtset id vague 


******* Labour estimates 
cd "$data/estimates"

eststo m1: xtreg leftRightW i.vague if pid6==2 & waves_taken120==20, fe
margins, at(vague=(1 2 3 4 5 6 7 8 9 10 11 12 15 16 17 18 19 20 21 22 23)) saving(results13, replace)

use results13.dta, clear

gen categories = 1 // labour partisans 

save results13.dta, replace 


******* Conservative estimates 

cd "$data"
use "panel.dta", clear 
cd "$data/estimates"
xtset id vague 

eststo m1: xtreg leftRightW i.vague if pid6==1 & waves_taken120==20, fe
margins, at(vague=(2 3 4 5 6 7 8 9 10 11 12 15 16 17 18 19 20 21 22 23)) saving(results14, replace)

use results14.dta, clear

gen categories = 2 // convservative partisans 

save results14.dta, replace 


******* independent estimates 

cd "$data"
use "panel.dta", clear 
cd "$data/estimates"

xtset id vague 

eststo m1: xtreg leftRightW i.vague if pid6==0 & waves_taken120==20, fe
margins, at(vague=(2 3 4 5 6 7 8 9 10 11 12 15 16 17 18 19 20 21 22 23)) saving(results15, replace)

use results15.dta, clear

gen categories = 3 // independent

save results15.dta, replace 

 

******* labour party's perceived position by labour partisans 
* waves 13, 14, and 19 are not available for this DV

cd "$data"
use "panel.dta", clear 
cd "$data/estimates"

xtset id vague 

eststo m1: xtreg lrLabW i.vague if pid6==2 & waves_taken120==20, fe
margins, at(vague=(2 3 4 5 6 7 8 9 10 11 12 15 16 17 18 20 21 22 23)) saving(results16, replace)

use results16.dta, clear

gen categories = 4 // labour party by labour partisans 

save results16.dta, replace 

 
 
******* conservative party's perceived position by conservative identifiers 
* waves 13, 14, and 19 are not available for this DV


cd "$data"
use "panel.dta", clear 
cd "$data/estimates"

xtset id vague 

eststo m1: xtreg lrConW i.vague if pid6==1 & waves_taken120==20, fe
margins, at(vague=(2 3 4 5 6 7 8 9 10 11 12 15 16 17 18 20 21 22 23)) saving(results17, replace)

use results17.dta, clear

gen categories = 5 // conservative party's perceived position by conservative partisans

save results17.dta, replace  
 
 
 ******* labour party's perceived position by conservative identifiers 
* waves 13, 14, and 19 are not available for this DV

 
cd "$data"
use "panel.dta", clear 
cd "$data/estimates"

xtset id vague 

eststo m1: xtreg lrLabW i.vague if pid6==1 & waves_taken120==20, fe
margins, at(vague=(2 3 4 5 6 7 8 9 10 11 12 15 16 17 18 20 21 22 23)) saving(results18, replace)

use results18.dta, clear

gen categories = 6 // labour party's perceived position by conservative partisans

save results18.dta, replace  
  
 
 
*now append these datasets 
 
cd "$data/estimates"
use "results13.dta", clear 
append using "results14.dta"
append using "results15.dta"
append using "results16.dta"
append using "results17.dta"
append using "results18.dta"


drop _deriv _term _predict _se_margin _statistic _pvalue 

rename _margin b
rename _ci_lb b_lower 
rename _ci_ub b_upper 
rename _at vague_updated // note that wave 1, 13, 14 and 19 are not available. Margins command will jump those and will not show them, the outcome will be as if there is no gaps from 1 to the last, hence use "_at1" variable. 


rename categories category


tsset category _at1 
 
twoway (tsline b if category==3, lcolor(gs7%100) lpattern(dash)) (tsline b_lower if category==3, lcolor(gs7%100) lpattern(solid)) (tsline b_upper if category==3, lcolor(gs7%100)) (tsline b if category==1, lcolor(cranberry%100) lpattern(dash)) (tsline b_lower if category==1, lcolor(cranberry%100) lpattern(solid)) (tsline b_upper if category==1, lcolor(cranberry%100) lpattern(solid)) (tsline b if category==4, lcolor(cranberry%50) lpattern(shortdash)) (tsline b_lower if category==4, lcolor(cranberry%50) lpattern(solid)) (tsline b_upper if category==4, lcolor(cranberry%50) lpattern(solid)) , legend(off) xline(6.5, lpattern(solid) lcolor(gs6%70)) tlabel(#30, labels labsize(vsmall) angle(vertical) valuelabel) ttitle("") graphregion(margin(5 5 15 5)) title("(a) Labour identifiers") yscale(range(0(2)8)) ytick(0 2 4 6 8) ylabel(0 2 4 6 8) 
graph save "${figures}/Figure9_2a.gph",replace 


twoway (tsline b if category==2, lcolor(navy%100) lpattern(dash)) (tsline b_lower if category==2, lcolor(navy%100) lpattern(solid)) (tsline b_upper if category==2, lcolor(navy%100) lpattern(solid)) (tsline b if category==5, lcolor(navy%50) lpattern(shortdash)) (tsline b_lower if category==5, lcolor(navy%50) lpattern(solid)) (tsline b_upper if category==5 , lcolor(navy%50) lpattern(solid))  (tsline b if category==6, lcolor(cranberry%50) lpattern(shortdash)) (tsline b_lower if category==6, lcolor(cranberry%50) lpattern(solid)) (tsline b_upper if category==6, lcolor(cranberry%50) lpattern(solid))  , legend(off) xline(6.5, lpattern(solid) lcolor(gs6%70)) tlabel(#30, labels labsize(vsmall) angle(vertical) valuelabel) xtitle("") graphregion(margin(5 5 15 5)) title("(b) Conservative identifiers") ytitle("")

graph save "${figures}/Figure9_2b.gph",replace 

 
cd "$figures"
graph combine "Figure9_2a.gph" "Figure9_2b.gph", ycommon xsize(15) ysize(17) row(2)
graph save "${figures}/Figure9_2.gph", replace 
